package maliklund87.spiritrpg.dao;



import java.util.HashMap;

import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;

public class ImageLoader {
	private static HashMap<String, Image> images = new HashMap<String, Image>();
	
	public static Image loadImage(String path){
		Image requestedImage = null;
		if (images.containsKey(path)){
			requestedImage = images.get(path);
		} else {
			try {
				requestedImage = new Image(path);
				images.put(path, requestedImage);
			} catch (SlickException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		return requestedImage;
	}
	
	public static void unloadImage(Image image){
		if (images.containsValue(image)){
			images.remove(image);
		}
	}
}
